#! /bin/bash
export LANG=zh_CN.UTF-8
HIVE_HOME=/usr/bin/hive


${HIVE_HOME} -S -e "
--分区
SET hive.exec.dynamic.partition=true;
SET hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.max.dynamic.partitions.pernode=10000;
set hive.exec.max.dynamic.partitions=100000;
set hive.exec.max.created.files=150000;
-------------------首次全量导入--------------------------------

insert overwrite table edu_dwd.dwd_dim_customer PARTITION (start_date)
select
    id,
    customer_relationship_id,
    create_date_time,
    update_date_time,
    deleted,
    name,
    idcard,
    birth_year,
    gender,
    phone,
    wechat,
    qq,
    email,
    area,
    leave_school_date,
    graduation_date,
    bxg_student_id,
    creator,
    origin_type,
    origin_channel,
    tenant,
    md_id,
    '9999-99-99' as end_date,
    dt as start_date
from edu_ods.customer
where id is not null;


insert overwrite table edu_dwd.dwd_dim_customer_appeal PARTITION (start_date)
select id,
       customer_relationship_first_id,
       employee_id,
       employee_name,
       employee_department_id,
       employee_tdepart_id,
       appeal_status,
       audit_id,
       audit_name,
       audit_department_id,
       audit_department_name,
       audit_date_time,
       create_date_time,
       update_date_time,
       deleted,
       tenant,
       '9999-99-99' as end_date,
       dt as start_date
from edu_ods.customer_appeal
where customer_relationship_first_id is not null;

insert overwrite table edu_dwd.dwd_dim_employee
select * from edu_ods.employee
where id is not null and tdepart_id is not null;

insert overwrite table edu_dwd.dwd_dim_itcast_school
select * from edu_ods.itcast_school
where id is not null and name is not null;

insert overwrite table edu_dwd.dwd_dim_itcast_subject
select * from edu_ods.itcast_subject
where id is not null and name is not null;

insert overwrite table edu_dwd.dwd_dim_scrm_department
select * from edu_ods.scrm_department
where id is not null and name is not null;
"